package com.zzq.service.impl;

import com.zzq.domain.dto.SmileBlindboxGoodsDTO;
import com.zzq.domain.entity.SmileBlindboxGoods;
import com.zzq.domain.search.BlindboxGoodsSearchParamet;
import com.zzq.result.SmileResult;
import com.zzq.service.BlindboxGoodsAdminService;
import com.zzq.service.SmileBlindboxGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

@Service
public class BlindboxGoodsAdminServiceImpl  implements BlindboxGoodsAdminService {
    @Autowired
    SmileBlindboxGoodsService blindboxGoodsService;

    @Override
    public SmileResult list(BlindboxGoodsSearchParamet searchParamet) {
        List<SmileBlindboxGoodsDTO> smileBlindboxGoodsDTOList = blindboxGoodsService.getSmileBlindboxGoodsDTOList(searchParamet);
        return SmileResult.sucess(smileBlindboxGoodsDTOList);
    }

    @Override
    public SmileResult add(SmileBlindboxGoods blindboxGoods) {
        blindboxGoodsService.save(blindboxGoods);
        blindboxGoodsService.updProbability();
        return SmileResult.sucess();
    }

    @Override
    public SmileResult upd(SmileBlindboxGoods blindboxGoods) {
        blindboxGoodsService.updateById(blindboxGoods);
        blindboxGoodsService.updProbability();
        return SmileResult.sucess();
    }

    @Override
    public SmileResult del(Long blindboxGoodsId) {
        blindboxGoodsService.removeById(blindboxGoodsId);
        blindboxGoodsService.updProbability();
        return SmileResult.sucess();
    }

}

